import { z } from "zod";

import { definePlugin } from "@/__registries__/plugins/utils";

declare module "@/__registries__/plugins/meta.types" {
  interface PluginsSettingsRegistry {
    "thread:messageTts": z.infer<typeof schema>;
  }
}

const schema = z.object({
  enabled: z.boolean(),
  playbackRate: z.number().min(0.75).max(2),
});

export default definePlugin({
  meta: {
    id: "thread:messageTts",
    title: "Text-to-Speech",
    description:
      "Enable text-to-speech for messages in threads. Requires a logged in account.",
    dashboardMeta: {
      tags: ["ui", "cometAssistant"],
      categories: ["thread", "comet"],
      uiRouteSegment: "thread-message-tts",
    },
    dependencies: {
      corePlugins: ["domObservers:thread:messageBlocks"],
      uiGroups: ["thread:messageBlocks:footer"],
    },
  },
  settingsSchema: {
    schema,
    fallback: {
      enabled: false,
      playbackRate: 1,
    },
  },
});
